<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Enables or disables internal report functions</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqli-driver.embedded-server-start.html">mysqli_driver::embedded_server_start</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.mysqli-warning.html">MySQLi_Warning</a></div>
 <div class="up"><a href="class.mysqli-driver.html">MySQLi_Driver</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqli-driver.report-mode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqli_driver::$report_mode</h1>
  <h1 class="refname">mysqli_report</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">mysqli_driver::$report_mode</span> -- <span class="refname">mysqli_report</span> &mdash; <span class="dc-title">Enables or disables internal report functions</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysqli-driver.report-mode-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="fieldsynopsis">
   <span class="type">int</span> <var class="varname"><a href="mysqli-driver.report-mode.html">$mysqli_driver-&gt;report_mode</a></var>
  ;</div>

  <p class="para">过程化风格</p>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><a href="function.mysqli-report.html" class="methodname">mysqli_report</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
   )</div>

  <p class="para rdfs-comment">
   A function helpful in improving queries during code development and testing. 
   Depending on the flags, it reports errors from mysqli function calls or 
   queries that don&#039;t use an index (or use a bad index).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysqli-driver.report-mode-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">flags</code></em></dt>

     <dd>

      <p class="para">
       <table class="doctable table">
        <caption><strong>Supported flags</strong></caption>
        
         <thead>
          <tr>
           <th>Name</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><strong><code>MYSQLI_REPORT_OFF</code></strong></td>
           <td>Turns reporting off</td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_ERROR</code></strong></td>
           <td>Report errors from mysqli function calls</td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_STRICT</code></strong></td>
           <td>
            Throw <a href="class.mysqli-sql-exception.html" class="classname">mysqli_sql_exception</a> for errors
            instead of warnings
           </td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_INDEX</code></strong></td>
           <td>Report if no index or bad index was used in a query</td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_ALL</code></strong></td>
           <td>Set all options (report all)</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysqli-driver.report-mode-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-mysqli-driver.report-mode-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.4</td>
       <td>
        Changing the reporting mode is now be per-request, rather than per-process.
       </td>
      </tr>

      <tr>
       <td>5.2.15</td>
       <td>
        Changing the reporting mode is now be per-request, rather than per-process.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mysqli-driver.report-mode-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1720">
   <p><strong>Example #1 面向对象风格</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"world"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;check&nbsp;connection&nbsp;*/<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">mysqli_connect_errno</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Connect&nbsp;failed:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">mysqli_connect_error</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;exit();<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;activate&nbsp;reporting&nbsp;*/<br /></span><span style="color: #0000BB">$driver&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli_driver</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$driver</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">report_mode&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">MYSQLI_REPORT_ALL</span><span style="color: #007700">;<br /><br />try&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;this&nbsp;query&nbsp;should&nbsp;report&nbsp;an&nbsp;error&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;Name&nbsp;FROM&nbsp;Nonexistingtable&nbsp;WHERE&nbsp;population&nbsp;&gt;&nbsp;50000"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;this&nbsp;query&nbsp;should&nbsp;report&nbsp;a&nbsp;bad&nbsp;index&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;Name&nbsp;FROM&nbsp;City&nbsp;WHERE&nbsp;population&nbsp;&gt;&nbsp;50000"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /><br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">mysqli_sql_exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">__toString</span><span style="color: #007700">();<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-1721">
   <p><strong>Example #2 过程化风格</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;activate&nbsp;reporting&nbsp;*/<br /></span><span style="color: #0000BB">mysqli_report</span><span style="color: #007700">(</span><span style="color: #0000BB">MYSQLI_REPORT_ALL</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysqli_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"world"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;check&nbsp;connection&nbsp;*/<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">mysqli_connect_errno</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Connect&nbsp;failed:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">mysqli_connect_error</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;exit();<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;this&nbsp;query&nbsp;should&nbsp;report&nbsp;an&nbsp;error&nbsp;*/<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysqli_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;Name&nbsp;FROM&nbsp;Nonexistingtable&nbsp;WHERE&nbsp;population&nbsp;&gt;&nbsp;50000"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;this&nbsp;query&nbsp;should&nbsp;report&nbsp;a&nbsp;bad&nbsp;index&nbsp;*/<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysqli_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;Name&nbsp;FROM&nbsp;City&nbsp;WHERE&nbsp;population&nbsp;&gt;&nbsp;50000"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">mysqli_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">mysqli_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mysqli-driver.report-mode-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="mysqli.debug.html" class="function" rel="rdfs-seeAlso">mysqli_debug()</a> - Performs debugging operations</span></li>
    <li class="member"><span class="function"><a href="mysqli.dump-debug-info.html" class="function" rel="rdfs-seeAlso">mysqli_dump_debug_info()</a> - 将调试信息输出到日志</span></li>
    <li class="member"><a href="class.mysqli-sql-exception.html" class="classname">mysqli_sql_exception</a></li>
    <li class="member"><span class="function"><a href="function.set-exception-handler.html" class="function" rel="rdfs-seeAlso">set_exception_handler()</a> - 设置一个用户定义的异常处理函数。</span></li>
    <li class="member"><span class="function"><a href="function.error-reporting.html" class="function" rel="rdfs-seeAlso">error_reporting()</a> - 设置应该报告何种 PHP 错误</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqli-driver.embedded-server-start.html">mysqli_driver::embedded_server_start</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.mysqli-warning.html">MySQLi_Warning</a></div>
 <div class="up"><a href="class.mysqli-driver.html">MySQLi_Driver</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
